<?php 

$peer = ProductAttendantPeer::getInstance();
$id = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
$select = $peer->select();
$select->where(ProductAttendantPeer::PRODUCT_ID, $id);
$rowset = $peer->fetchAll($select);

$count = $rowset->count();
echo "<label><b>Сопутствующие товары ($count):</b></label><br />";
foreach ($rowset as $row) {
	$product = ProductPeer::getInstance()->find($row->getAttendantId())->current();
	$url = $this->url(array('id' => $product->getId()));
	echo "
	<a href='$url'>{$product->getName()}</a>
	&nbsp;&nbsp;
	<a href='#' class='delete_alike' type='attendant' row_id='{$product->getId()}'>[ x ]</a>
	<br />";
}

echo "<div class='container_alike'>
<label>Добавить сопутствующий товар (по имени) <a href='#' class='add_alike' type='alike'>[ + ]</a></label>
";
$request = Zend_Controller_Front::getInstance()->getRequest();
$alikes = $request->getParam('attendant', array());
$first = 1;
foreach ($alikes as $alike) {
	if ($first) {
		$first = 0;
		continue;
	}
	
	if (!$alike) continue;
	echo 
	"<div class='alike_element'>
		<input type='text' autocomplete='off' name='attendant[]' class='alike_suggest' type='attendant' value='$alike' />
		<div class='suggest_result'></div>
	</div>";
}

echo "
	<div class='alike_element'>
		<input type='text' autocomplete='off' name='attendant[]' class='alike_suggest' type='attendant'/>
		<div class='suggest_result'></div>
	</div>
</div>";




